﻿using BasicInformation.ApiRead.Application.Command.Depot;
using BasicInformation.Domain;
using BasicInformation.ErrorCode;
using BasicInformation.Infrastructure.Implement;
using BasicInformation.Infrastructure.Interface;
using MediatR;

namespace BasicInformation.ApiRead.Application.Handler.Depot
{
    public class GetDepotTypeHandler : IRequestHandler<GetDepotTypeCommand, ApiPaging<DepotTypeModel>>
    {
        private readonly IBaseRepository<DepotTypeModel> depotTypeReop;
        private readonly DatabaseContext db;
        private readonly ILogger<GetDepotTypeHandler> logger;

        public GetDepotTypeHandler(DatabaseContext db,ILogger<GetDepotTypeHandler> logger)
        {
            this.depotTypeReop = depotTypeReop;
            this.db = db;
            this.logger = logger;
        }
        public async Task<ApiPaging<DepotTypeModel>> Handle(GetDepotTypeCommand request, CancellationToken cancellationToken)
        {
            ApiPaging<DepotTypeModel> result = new ApiPaging<DepotTypeModel>();
            var sql = @"SELECT * FROM depottypemodel WHERE 1=1 ";
            var res = db.SqlSugar.Queryable<DepotTypeModel>();
            result.Data = res.ToList();
            result.Code = ApiEnum.OK;
            result.Msg = "显示成功";
            logger.LogInformation(result.Msg);
            return await Task.FromResult(result);
        }
    }
}
